<?php

/**
 * Created by PhpStorm.
 * User: fanfz_000
 * Date: 2015/4/7 0007
 * Time: 18:23
 * 作用 ：图片轮播列表
 */
class Backgroudurl_model extends CI_Model
{

    var $Id = '';
    var $url = '';

    function __construct()
    {
        parent::__construct();
    }

    function show_image_list()
    {
        $this->db->cache_on();
        $query = $this->db->get('backgroud_url');
        $data = $query->result_array();
        return array(
            'total' => $this->db->count_all_results('backgroud_url'),
            'data_num' => count($data),
            'image' => $data

        );
    }
    /*上传图片轮播*/
    /*添加上传图片轮播记录失败，日志信息添加功能 2015-5-1*/
    function upload_image($photo_href)
    {
        $data = array(
            'url' => $photo_href
        );
        $bool = $this->db->insert('backgroud_url', $data);
        if ($bool) {
            //更新成功
            echo $this->db->insert_id();
        } else {
            //数据异常
            $system_blog = array(
                'text' => '上传图片轮播，记录失败。新增的图片的路径为' . $photo_href . ',sql:' . $this->db->last_query(),
                'date' => date('Y-m-d')
            );
            $this->db->insert('system_blog', $system_blog);
            echo "-1";
        }
    }
}
